package cn.tedu.map;

public class TestRunnable {
    public static void main(String[] args) {
        /*如果想以多线程方式启动实现业务类，需要借助Thread
        * 实现runnable接口共享数据不需要使用域变量*/
        new Thread(new TickerRunnable()).start();
        new Thread(new TickerRunnable()).start();
        new Thread(new TickerRunnable()).start();

    }
}
class TickerRunnable implements Runnable{
    private static int ticket=100;
    @Override
    public synchronized void run() {
while (true){
    System.out.println(Thread.currentThread().getName()+"=\t"+ticket--);

    if (ticket<=0){
        break;
    }
}
    }
}
